package com.baidu.service;

import com.baidu.dao.AirDao;
import com.baidu.entity.AirBean;
import com.baidu.entity.DistrictBean;
import com.baidu.utils.Page;

import java.util.Date;
import java.util.List;

/**
 * 创作时间：2019/9/19 9:14
 * 作者：李增强
 */
public class AirService {
    AirDao dao = new AirDao();
    public List<AirBean> getAirList(Page page, String id) {
        String ssql="";
        if(id!=null&&!"-1".equals(id)){
            ssql+=" and districtid="+id;
        }

        ssql+=" order by monitortime desc ";

        ssql+=" limit "+page.getStartRecord()+","+page.getPageSize();
        return dao.getAirList(ssql);
    }

    public List<DistrictBean> getDistrictList() {

        return dao.getDistrictList();
    }

    public int getAirCount(String id) {
        String ssql="";
        if(id!=null&&!"-1".equals(id)){
            ssql+=" and districtid="+id;
        }
        return dao.getAirCount(ssql);
    }

    public AirBean getAirById(String id) {
        return dao.getAirById(id);
    }

    public boolean deleteAirById(String id) {
        return dao.deleteAirById(id);
    }

    public void updateAir(String districtid, String monitortime, String pm10, String pm25, String monitoringstation, String id) {
        Date lastmodifytime = new Date();

        dao.updateAir(districtid,monitortime,pm10,pm25,monitoringstation,lastmodifytime,id);
    }
}
